package org.hang.gift.controller;


import org.hang.gift.service.IVerifyCodeService;
import org.hang.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 专门用来发送短信验证码的类
 */

@RestController
@RequestMapping("/user/verifyCode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    /**
     * 用户注册时，获取手机验证码
     * @param phone
     * @return
     */

    @GetMapping("/register/sendSms/{phone}")
    public AjaxResult userRegisterSendSms(@PathVariable("phone") String phone){
        try {
            verifyCodeService.userRegisterSendSms(phone);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("发送验证码失败");
        }

    }



}
